{include file='comdir/head.html'}
<link href="{$_URL}static/admin/css/evol.colorpicker.min.css" rel="stylesheet">
<script src="{$_URL}static/js/jquery-ui-1.10.2.js"></script>
<script src="{$_URL}static/js/evol.colorpicker.min.js"></script>
<style type="text/css">
{literal}
.col-lg-3,.col-lg-7,.col-lg-1,.col-lg-11{width: 200px;display: inline;float: none;}
.form-control{display: inline;width: 200px;}
#cpButton{display: inline;width:100px;vertical-align: middle;}
.evo-cp-wrap{display: inline;}
.video_url{width:44.5%;}
.select_select_size{width:65px;}
.title_size{width:60px;display:inline-block;text-align: right;}
.title_width{width:44.5%;}
.textarea_size{width:600px;height: 500px;vertical-align: middle;}
.input[type="submit"].btn-block, input[type="reset"].btn-block, input[type="button"].btn-block {width:100px;margin-left: 75px;}
.hits{width:100px;}
{/literal}
</style>
<body>
<div class="content">
	<div class="animated fadeInDown">
		<div class="pos"><a href="#" onClick="javascript :history.back(-1);">返回上一页</a></div>
		<form class="form-horizontal article" action="javascript:void(0)" id='frm'>
			<div class="form-group">
				<span class="title_size">栏目</span>
				
				<div class="col-lg-3">
					<select class="form-control columnselected" disabled name="colid">
						<option value="">选择栏目</option>>
						{$columnselected}
					</select>
					<input type="hidden" class='sitesid' name="sitesid" value="">
				</div>
			</div>
			<div class="form-group">
				
				<span class="title_size">标题</span>
				<div class="col-lg-7">
					<input type="text" class="form-control title_width" value="{$list.title}" name="title">
				</div>
				
				<span class="title_size">颜色</span>
				<div class="col-lg-3">
					<input id="cpButton" class="form-control" name="titilecolor" value="{$list.titilecolor}"  />
				</div>
			</div>
			<div class="form-group">
				<span class="title_size">来源</span>
				
				<div class="col-lg-3">
					<input type="text" value="{$list.copyfrom}" class="form-control" name="copyfrom">
				</div>
				<span class="title_size">审核人</span>
			
				<div class="col-lg-1">
					<input type="text" value="{$list.verifyuser}" class="form-control" name="verifyuser">
				</div>
				<span class="title_size">终审人</span>
				<div class="col-lg-1">
					<input type="text" value="{$list.finalverify}" class="form-control" name="finalverify">
				</div>
			</div>
			<div class="form-group">
			<span class="title_size">视频URL</span>
				
				<div class="col-lg-11">
					<input type="text" value="{$list.mediafile}" class="form-control video_url" name="mediafile">
				</div>
			</div>
			<div class="form-group img_show_hide" {if $list.defaultpicurl==''}  style="display: none;" {/if}>
			<span class="title_size">显示图片</span>
				<!-- <label class="col-lg-1 control-label">图片</label> -->
				<div class="col-lg-11">
					<img class="show_article" style="width:100px;height:30px;margin-bottom: 5px;" src="{$getConfig.upload_http}{$list.defaultpicurl}" />
					<div class="checkbox checkbox-inline">
						<input type="checkbox" id="delupload1" class='delupload' value="0">
						<label for="delupload1">取消标题图片</label>
					</div>
				</div>
			</div>
			<div class="form-group">
			<span class="title_size">图片</span>
				<!-- <label class="col-lg-1 control-label">图片</label> -->
				<div class="col-lg-11">
					<input type="hidden" value="{$list.defaultpicurl}" name="defaultpicurl"  class="article">
					<div class="iframe-box btn-blue">
						<iframe id="upiframe" frameborder="0" scrolling="no" src="{$_URL}Ups/upone?method=article&classname=article&callback=articleback"></iframe>
					</div>
				</div>
			</div>


			
			<div class="form-group">
			<span class="title_size">点击量</span>
				
				<div class="col-lg-1">
					<input type="text" class="form-control hits" name="hits" value="{$list.hits}">
				</div>
				<span class="title_size">推荐</span>
				
				<div class="col-lg-1">
					<select class="form-control select_select_size" name="recommendflag">
						<option value='0' {if $list.recommendflag==0} selected {/if} >否</option>
						<option value='1' {if $list.recommendflag==1} selected {/if}>是</option>
					</select>
				</div>
				<span class="title_size">置顶</span>
				
				<div class="col-lg-1">
					<select class="form-control select_select_size" name="headflag">
						<option value='0' {if $list.recommendflag==0} selected {/if}>否</option>
						<option value='1' {if $list.recommendflag==1} selected {/if} >是</option>
					</select>
				</div>
				<span class="title_size">审核</span>
				
				<div class="col-lg-1">
					<select class="form-control select_select_size" name="verify" >
						<option value='0'  {if $list.verify==0} selected {/if} >否</option>
						<option value='1'  {if $list.verify==1} selected {/if} >是</option>
					</select>
				</div>
			</div>
			<div class="form-group">
			<span class="title_size">简介</span>
				
				<div class="col-lg-11"><textarea class="form-control textarea_size" name="intro">{$list.intro}</textarea></div>
			</div>
			<div class="form-group">
			<span class="title_size">内容</span>
				
				<div class="col-lg-11">
					{include file='comdir/ueditor.html'}
				</div>
			</div>
			<div class="form-group">
				<div class="col-lg-offset-1 col-lg-11">
					<input type="hidden" name="infoid" value="{$list.infoid}">
					<input type="hidden" name="addtime" value="{$list.addtime}">
					<input type="button" class="btn btn-block btn-blue sub" name="name" value="提交">
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
	$('#cpButton').colorpicker({
		showOn:'button'
	});
	var _URL='{$_URL}';
	{literal}
		function articleback(data){
			var classname=data.classname;
			$('.'+classname).val(data.img);
			$('.img_show_hide').show();
			$('.show_'+classname).attr('src',data.imgshow);
		}
		function addauthorstr(arr,type){
			var arr_length=arr.length;
			var id='';
			var html='';
			for(i=0;i<arr_length;i++){
				if(arr[i]!=''){
					var arrdata=arr[i].split('_');
					id+=arrdata[0]+",";
					if(type==1){
						html+='<tr class="author_'+arrdata[0]+'"><td>'+arrdata[2]+'</td><td>'+arrdata[1]+'</td><td><input type="button" onClick="author_del('+arrdata[0]+')" value="删除"></td></tr>';
					}else{
						html+='<tr class="photoauthor_'+arrdata[0]+'"><td>'+arrdata[2]+'</td><td>'+arrdata[1]+'</td><td><input type="button" onClick="photoauthor_del('+arrdata[0]+')" value="删除"></td></tr>';
					}
				}
			}
			var result=new Array();
			id=id.substring(0,id.length-1);
			result['id']=id;
			result['html']=html;
			return result;
		}
		//删除选定作者
		function author_del(id){
			var author_value=$('.author_input_value').val();
			var old_arr=author_value.split(',');
			var arr_length=old_arr.length;
			var str='';
			for(i=0;i<arr_length;i++){
				if(id!=old_arr[i]){

					str+=old_arr[i]+',';
				}
			}
			if(str!=''){
				str=str.substring(0,str.length-1);
			}

			$('.author_input_value').val(str);
			$('.author_'+id).remove();
		}
		//删除选定摄影
		function photoauthor_del(id){
			var author_value=$('.photoauthor_input_value').val();
			var old_arr=author_value.split(',');
			var arr_length=old_arr.length;
			var str='';
			for(i=0;i<arr_length;i++){
				if(id!=old_arr[i]){

					str+=old_arr[i]+',';
				}
			}
			if(str!=''){
				str=str.substring(0,str.length-1);
			}

			$('.photoauthor_input_value').val(str);
			$('.photoauthor_'+id).remove();
		}
		$(".author_photoauthor").hide();
		//作者回调函数
		function author(sutidstr){
			if(sutidstr){
				//获取原数据
				var old_author=$('.author_input_value').val();
				var arr=sutidstr.split(',');
				if(old_author!=''){//已经存在作者
					var new_arr=new Array();
					//旧
					var old_arr=old_author.split(',');
					var old_length=old_arr.length;
					//新
					var arr_length=arr.length;
					for(i=0;i<arr_length;i++){//去掉重复的学生
						var isexits=false;
						var arrdata=arr[i].split('_');
						for(j=0;j<old_length;j++){
							if(arrdata[0]==old_arr[j]){
								arr[i]='';
							}
						}

					}
					var res=addauthorstr(arr,1);
					res['id']=$('.author_input_value').val()+','+res['id'];
				}else{
					var res=addauthorstr(arr,1);
				}
				$('.author_photoauthor1').append(res['html']);
				$('.author_input_value').val(res['id']);
				$(".author_photoauthor1").show();
				
			}
			layer.close(layer.index);
		}
		//摄影回调函数
		function photoauthor(sutidstr){
			if(sutidstr){
				//获取原数据
				var old_author=$('.photoauthor_input_value').val();
				var arr=sutidstr.split(',');
				if(old_author!=''){//已经存在作者
					var new_arr=new Array();
					//旧
					var old_arr=old_author.split(',');
					var old_length=old_arr.length;
					//新
					var arr_length=arr.length;
					for(i=0;i<arr_length;i++){//去掉重复的学生
						var isexits=false;
						var arrdata=arr[i].split('_');
						for(j=0;j<old_length;j++){
							if(arrdata[0]==old_arr[j]){
								arr[i]='';
							}
						}

					}
					var res=addauthorstr(arr,2);
					res['id']=$('.photoauthor_input_value').val()+','+res['id'];
				}else{
					var res=addauthorstr(arr,2);
				}
				$('.author_photoauthor2').append(res['html']);
				$('.photoauthor_input_value').val(res['id']);
				$(".author_photoauthor2").show();
				
			}
			layer.close(layer.index);
		}
		$(function(){
			//取消图片
			$('.delupload').change(function(){
				var value=$(this).is(':checked');
				if(value){
					$('.img_show_hide').hide();
					$('.article').val('');
					$(this).val(1);
				}else{
					$(this).val(0);
				}

			})
			//选择栏目获取站点id
			$('.columnselected').change(function(){
				var sitesid=$('.columnselected').find('option:selected').attr('data-sites');
				$('.sitesid').val(sitesid);
			})
			//专题分类事件
			$('.specialid').change(function(){
				var specialid=$(this).val();
				if(specialid==''){return false;}
				var url=_URL+'Article/add';
				_ajaxs.post(url,'specialcontenttype=1&specialid='+specialid,function(data){
					var html='';
					html+='<select class="form-control specialtypeid" name="specialtypeid">';

					if(!data.status){
						html+='<option value="">无专题内容分类</option>';
					}else{
						var list=data.data;
						var list_length=list.length;
						for(i=0;i<list_length;i++){
							html+='<option value="'+list[i]['id']+'">'+list[i]['ctypename']+'</option>';
						}
					}

					html+='</select>';
					$('.specialtypeid').remove();
					$('.specialcontnetadd').html(html);
				})
			})
			//添加作者
			$('.author').click(function(){
				//默认已选的当前作者
				var author_input_value=$('.author_input_value').val();
				var layer_author=layer.open({
					type: 2,
					area: ['800px', '600px'],
					title:'作者选择',
					fixed: false, //不固定
					maxmin: true,
					content: _URL+"Article/add?author=1&author_photoauthor_value="+author_input_value
				});
			})
			//添加摄影
			$('.photoauthor').click(function(){
				var photoauthor_input_value=$('.photoauthor_input_value').val();
				var layer_photoauthor=layer.open({
					type: 2,
					area: ['800px', '600px'],
					title:'摄影选择',
					fixed: false, //不固定
					maxmin: true,
					content: _URL+"Article/add?author=2&author_photoauthor_value="+photoauthor_input_value
				});
			})
			var subadd=true;
			$('.sub').click(function(){
				var url=_URL+"Article/edit";
				var formjquery=_ajaxs.from('#frm');
				if(!subadd){return false;}
				//subadd=false;
				_ajaxs.post(url,'formjquery='+formjquery,function _result(data){
					subadd=true;
					layer.msg(data.msg,{icon: 1}, function(){
						if(data.status){
							window.location.href=_URL+"Article/lists";
						}
					});

				});
			})
		})
	{/literal}
</script>
</body>
</html>
